import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '../views/Home.vue'
import News from '../views/News.vue'
import New from '../views/New.vue'
import Work from '../views/Work.vue'
import Login from '../views/Login.vue'
import Payment from '../views/Payment.vue'
import Myself from '../views/Myself.vue'
import  NProgress  from 'nprogress'
import 'nprogress/nprogress.css'

const routes = [
  {
    path: '/',
    name: 'login',
    component: Login
  },
  {
    path: '/news',
    name: 'news',
    component: News
  },
  {
    path: '/home',
    name: 'home',
    component: Home
  },
  {
    path: '/news/:id',
    name: 'new',
    component: New
  },
  {
    path: '/work',
    name: 'work',
    component: Work
  },
  {
    path: '/payment',
    name: 'payment',
    component: Payment
  },
  {
    path: '/myself',
    name: 'myself',
    component: Myself
  },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

router.beforeEach((to,from,next)=>{
  NProgress.start()
  next()
})
router.afterEach((to,from,next)=>{
  NProgress.done()
})
export default router
